// 统一管理网络请求方法
import request from '@/utils/request'

// 封装接口请求的方法
// 定义一个函数，分别导出，设置url地址
export const allChannelListAPI = () => {
  // console.log(request)
  // request看成一个函数
  return request({ url: '/v1_0/channels' })
}
// 之后其他的请求地址，都书写在此页面
export const LoginApi = ({ mobile, code }) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}
// 滚动列表
export const userChannelAPI = () => {
  return request({
    url: '/v1_0/user/channels'
  })
}

// 文章列表
export const articlesListAPI = ({ channel_id, timestamp }) => {
  return request({
    url: '/v1_0/articles',
    params: {
      channel_id: channel_id,
      timestamp: timestamp || (new Date()).getTime()
    }
  })
}
// 不感兴趣
export const articleDislikeAPI = ({ target }) => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: target
    }
  })
}
// 举报文章
export const articleReportsAPI = ({ target, type, remark }) => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'POST',
    data: {
      target: target,
      type: type,
      remark: remark
    }
  })
}
// 用户频道覆盖
export const FgaiReportsAPI = ({ channels }) => {
  return request({
    url: '/v1_0/user/channels',
    method: 'PUT',
    data: {
      channels
    }
  })
}
// 联想搜索
export const SuggestionAPI = ({ q }) => {
  return request({
    url: '/v1_0/suggestion',
    params: {
      q: q
    }
  })
}
